//
//  MainViewController.m
//  BuDeJie
//
//  Created by 许良 on 16/7/21.
//  Copyright © 2016年 fading. All rights reserved.
//

#import "MainViewController.h"
#import "EssenceViewController.h"
#import "FriendTremdsViewController.h"
#import "MeViewController.h"
#import "NewViewController.h"
#import "FadTabBar.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //自定义字体
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    selectAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
    
    //自定义子控制器
    [self addChildViewController:[[EssenceViewController alloc ]init] ItemTitle:@"精华" imageNamed:@"tabBar_essence_icon" selectedImage:@"tabBar_essence_click_icon"];
    [self addChildViewController:[[NewViewController alloc ]init] ItemTitle:@"新帖" imageNamed:@"tabBar_new_icon" selectedImage:@"tabBar_new_click_icon"];
    [self addChildViewController:[[FriendTremdsViewController alloc ]init] ItemTitle:@"关注" imageNamed:@"tabBar_friendTrends_icon" selectedImage:@"tabBar_friendTrends_click_icon"];
    [self addChildViewController:[[MeViewController alloc ]init] ItemTitle:@"我的" imageNamed:@"tabBar_me_icon" selectedImage:@"tabBar_me_click_icon"];
    

    [self setValue:[[FadTabBar alloc]init] forKey:@"tabBar"];
    
}


- (void)addChildViewController:(UIViewController *)vc ItemTitle:(NSString *)ItemTitle imageNamed:(NSString*)imageNamed selectedImage:(NSString *)selectedImage{
    vc.navigationItem.title = ItemTitle;
    vc.tabBarItem.title = ItemTitle;
    vc.tabBarItem.image = [UIImage imageNamed:imageNamed];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage];
//    vc.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(100)/100.0 green:(100)/100.0 blue:(100)/100.0 alpha:1.0];
    
    //NAV
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    [self addChildViewController:nav];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
